
import axios from 'axios'
export const getPositionCity = () => {
    const localStorageCity = JSON.parse(localStorage.getItem("hkzf_city"))
    if (localStorageCity) {
        return Promise.resolve(localStorageCity)
    } else {
        return new Promise((resolve, rejected) => {
            const myCity = new window.BMapGL.LocalCity();
            myCity.get(async res => {
                try{
                    const result = await axios.get(`http://localhost:8007/area/info?name=${encodeURIComponent(res.name)}`)
                    localStorage.setItem("hkzf_city",JSON.stringify(result.data.body))
                    resolve(result.data.body)
                }catch (e){
                    console.log(e,"失败")
                    rejected(e)
                }
            });
        })
    }
}
// curCityName:result.data.body.label